Object.defineProperty(exports, "__esModule", {
  value: true
});
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_VIVO_CustomAdMgr = /* */function () {
  function _ctor() {
    babel_classCallCheck(this, _ctor);
    this.CustomAds = new Map();
    this.CustomAdOpen = new Map();
  }
  return babel_createClass(_ctor, [{
    key: "Create",
    value: function Create(e, t) {
      var _this143 = this;
      var n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 120;
      if (!(window.qg.getSystemInfoSync().platformVersionCode <= 1050) && (console.log("创建原生模板广告2:", e), window.qg && !this.CustomAds.has(e))) {
        console.log("CustomAds", e);
        var _t71 = null;
        (_t71 = "db62d7cf3ae54dd681ca79401c0c4d2d" == e ? window.qg.createCustomAd({
          adUnitId: e,
          style: {}
        }) : window.qg.createCustomAd({
          adUnitId: e,
          style: {
            top: 720
          }
        })).onLoad(function () {
          console.log("原生模板广告加载成功");
        });
        _t71.onError(function (t) {
          _this143.CustomAdOpen.set(e, false);
          _this143.Destroy(e);
          console.log("原生模板广告加载错误", JSON.stringify(t));
        });
        _t71.onClose(function () {
          console.log("原生模板广告关闭 onClose");
          _this143.CustomAdOpen.set(e, false);
        });
        _t71.onHide(function () {
          console.log("原生模板广告关闭 onHide");
          _this143.CustomAdOpen.set(e, false);
        });
        console.log("CustomAds 创建完成");
        this.CustomAds.set(e, _t71);
      }
    }
  }, {
    key: "Show",
    value: function Show(e, t) {
      var _this144 = this;
      var n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 120;
      console.log("CustomAd:", this.CustomAds.get(e), this.CustomAdOpen.get(e));
      this.CustomAds.has(e) || this.Create(e, t, n);
      if (this.CustomAdOpen.get(e)) {
        console.log("显示中");
      } else {
        console.log("CustomAd Show");
        this.CustomAdOpen.set(e, true);
        this.CustomAds.get(e).show().then(function () {
          0 == _this144.CustomAdOpen.get(e) && _this144.Hide(e);
          console.log("原生广告显示");
        }).catch(function () {
          _this144.CustomAdOpen.set(e, false);
          console.log("原生广告显示失败");
        });
      }
    }
  }, {
    key: "Hide",
    value: function Hide(e) {
      console.log("隐藏原生广告+++++", e);
      this.CustomAdOpen.set(e, false);
      this.CustomAds.has(e) && this.CustomAds.get(e).hide();
    }
  }, {
    key: "Destroy",
    value: function Destroy(e) {
      console.log("销毁原生广告:", e);
      if (this.CustomAds.has(e)) {
        this.CustomAds.get(e).offError();
        this.CustomAds.get(e).offClose();
        this.CustomAds.get(e).offHide();
        this.CustomAds.get(e).destroy();
        this.CustomAds.delete(e);
      }
    }
  }], [{
    key: "Instance",
    get() {
      _ctor._instance || (_ctor._instance = new _ctor());
      return _ctor._instance;
    }
  }]);
}();
exports.default = def_VIVO_CustomAdMgr;